package com.reggie.lotterysystem.dao.mapper;

import com.reggie.lotterysystem.dao.dataobject.PrizeDO;
import jakarta.validation.constraints.NotNull;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface PrizeMapper {

    @Insert("insert into prize(name, price,image_url, description) " +
            "values ( #{name}, #{price}, #{imageUrl}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "id",keyColumn = "id")
    Long insert(PrizeDO prizeDO);

    @Select("select count(1) from prize")
    int count();

    @Select("select * from prize order by id desc limit #{offset},#{pageSize}")
    List<PrizeDO> selectPrizeList(Integer offset, Integer pageSize);


    List<Long> selectExistByIds(List<Long> prizeIds);

    List<PrizeDO> batchSelectByIds(List<Long> prizeIds);

    @Select("select * from prize where id = #{prizeId}")
    PrizeDO selectById( Long prizeId);
}
